<?php
//echo "<script type='text/javascript'>alert('测试');</script>";
session_start();
require 'lyb_conn.php';
$lyb_id = uniqid();
//if($_SERVER["REQUEST_METHOD"]=="POST"){
if (isset($_POST['tijiao'])) {
    if (isset($_SESSION['user'])) {
        $sql = "insert into n1(id,user,title,content) values('$lyb_id','$_SESSION[user]','$_POST[title]','$_POST[content]')";
    } else {
        $sql = "insert into n1(id,user,title,content) values('$lyb_id','guest','$_POST[title]','$_POST[content]')";
    }
    mysqli_query($con, $sql);
    echo "<script type='text/javascript'>alert('保存成功！');</script>";
    echo "<script type='text/javascript'>window.location.href='index.php';</script>";
}
?>
<html>
    <head>
        <title>
            提交页面
        </title>
        <meta charset="utf-8">
    </head>
    <body>
        <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]) ?>">
            标题：<input name="title">
            <br><br>
            内容：<textarea name="content" rows="5" cols="20"></textarea>
            <br><br>
            <input type="submit" name="tijiao" value="提交">
        </form>
    </body>
</html>


